﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bizu.Models;
using Newtonsoft.Json;

namespace Bizu.Controllers
{
    public class HomeController : Controller
    {

        BizuEntities db = new BizuEntities();

        public ActionResult Index()
        {

            return View();
        }

        public string getNewPost(int page) 
        {
            var q = (from p in db.bizu_Post
                     select new
                     {
                         idPost = p.id,
                         titlePost = p.title,
                         datePost = p.date_post,
                         contentPost = p.content_post
                     }).OrderByDescending(o => o.datePost).Skip(page * 0).Take(5).ToList();

            return JsonConvert.SerializeObject(q);
        }

    }
}
